package com.github.vortexdev.yachtclub.services;

import com.github.vortexdev.yachtclub.models.Yacht;
import com.github.vortexdev.yachtclub.util.db.Page;
import com.github.vortexdev.yachtclub.util.db.Sort;
import com.github.vortexdev.yachtclub.repository.YachtRepository;

import java.util.List;
import java.util.Map;

/**
 * @author Sergey Parakhin (sergey.parahin@gmail.com)
 */
public class YachtService {
    YachtRepository yachtRepository;

    public void setYachtRepository(YachtRepository yachtRepository) {
        this.yachtRepository = yachtRepository;
    }

    public List<Yacht> getYachtsWithOwnerNames(Page page) {
        return yachtRepository.findYachtsWithOwnerNames(page);
    }

    public List<Yacht> getYachtsWithOwnerNames(Page page, Sort sort) {
        return yachtRepository.findYachtsWithOwnerNames(page, sort);
    }

    public List<Yacht> getYachtsWithOwnerNames(Page page, Map<String, Object> criteria) {
        return yachtRepository.findYachtsWithOwnerNames(page, criteria);
    }

    public List<Yacht> getYachtsWithOwnerNames(Page page, Map<String, Object> criteria, Sort sort) {
        return yachtRepository.findYachtsWithOwnerNames(page, criteria, sort);
    }

    public int countYachts() {
        return yachtRepository.countYachts();
    }

    public void saveYacht(Yacht yacht) {
        yachtRepository.save(yacht);
    }

    public Yacht getYacht(int id) {
        return yachtRepository.find(id);
    }

    public Yacht getYachtWithOwnerName(int id) {
        return yachtRepository.findWithOwnerName(id);
    }

}
